package com.illtamer.infinite.derive.util;

import com.illtamer.infinite.derive.AssertException;

public class Assert {

    public static void notNull(Object obj, String message) {
        notNull(obj, message, (Object) null);
    }

    public static void notNull(Object obj, String message, Object... args) {
        doAssert(obj == null, message, args);
    }

    public static void isTrue(boolean expression, String message) {
        isTrue(expression, message, (Object) null);
    }

    public static void isTrue(boolean expression, String message, Object... args) {
        doAssert(!expression, message, args);
    }

    private static void doAssert(boolean condition, String message, Object... args) {
        if (condition)
            throw new AssertException(args.length == 0 ? message : String.format(message, args));
    }

}
